package cn.humaohua.study.yanmo_design_pattern.ch13.v4;

import java.util.ArrayList;
import java.util.List;

public class CommandQueue {
    private static List<Command> cmds = new ArrayList<Command>();

    public static synchronized void addMenu(MenuCommand menuCommand) {
        for (Command cmd : menuCommand.getCmds()) {
            cmds.add(cmd);
        }
    }

    public static synchronized Command getOneCommand() {
        Command command = null;
        if (cmds.size() > 0) {
            command = cmds.remove(0);
        }
        return command;
    }
}
